/*
 * @(#)AssociationSourceModelFilter.java
 * Date 2013-09-30
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.registry.query;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import us.hornerscorners.lamppost.model.IFilter;

import us.hornerscorners.lamppost.model.common.PersistableModelType;

import us.hornerscorners.lamppost.model.document.Association;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-09-30
 * @author         Jim Horner    
 */
public class AssociationSourceModelFilter implements IFilter<Association> {

    /** Field description */
    private final List<PersistableModelType> modelTypes;

    /**
     * Constructs ...
     *
     *
     * @param modelTypes
     */
    public AssociationSourceModelFilter(PersistableModelType... modelTypes) {

        super();
        this.modelTypes = new ArrayList<>();
        this.modelTypes.addAll(Arrays.asList(modelTypes));
    }

    /**
     * Method description
     *
     *
     * @param item
     *
     * @return
     */
    @Override
    public boolean accept(Association item) {

        return this.modelTypes.contains(item.getSourceModelType());
    }
}
